#!/usr/bin/python3
# -*- coding: utf-8 -*-
import pandas as pd
import numpy  as np


def signal(*args):
    # ZhenFu
    df = args[0]
    n = args[1]
    factor_name = args[2]

    df['振幅'] = (df['high'] - df['low']) / df['open'] - 1
    df[factor_name] = df['振幅'].rolling(n).std(ddof=0)
    del df['振幅']

    return df